<?php
/**
 * @package qBase
 * @subpackage web
 * 
 */

/**
 * QWebSession represents the a web session
 * 
 * @package qBase
 * @subpackage web
 */
final class QWebSession extends QObject
{
	/**
	 * The constructor of the session object
	 *
	 */
	public function __construct()
	{
		
	}
	
	/**
	 * Starts a new session or resumes an existing one
	 *
	 */
	public function startOrResume()
	{
		if (!isset($_SESSION))
			session_start();
	}
	
	/**
	 * Sets a session variable
	 *
	 * @param string $key
	 * @param mixed $value
	 */
	public function setVariable($key, $value)
	{
		$_SESSION[$key] = $value;
	}
	
	/**
	 * Gets a sesssion variable
	 *
	 * @param string $key
	 * @return mixed
	 */
	public function getVariable($key)
	{
		if (isset($_SESSION[$key]))
			return $_SESSION[$key];
		else 
			return null;
	}
	
	/**
	 * Unsets a session variable. Returns true if the variable has been found and removed.
	 *
	 * @param string $key
	 * @return boolean
	 */
	public function unsetVariable($key)
	{
		if (isset($_SESSION[$key]))
		{
			unset ($_SESSION[$key]);
			return true;
		}
		else 
			return false;
	}
}


?>